package com.example.a17376046_xsh_finaltest.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.a17376046_xsh_finaltest.R;
import com.example.a17376046_xsh_finaltest.banner.MyBanner;
import com.example.a17376046_xsh_finaltest.zing.activity.CaptureActivity;

public class HomeFragment extends Fragment {
    private LinearLayout searchLinearLayout,collectLinearLayout,activityLinearLayout,myOrderLinearLayout,dynamicLinearLayout,wusiLinearLayout;
    private LinearLayout sweepLinearLayout,navigationLinearLayout,mapLinearLayout,helpLinearLayout,myBalanceLinearLayout,memberLinearLayout;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         // TODO Auto-generated method stub
        View view = inflater.inflate(R.layout.fragment_home,container,false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        searchLinearLayout=view.findViewById(R.id.search_LinearLayout);
        collectLinearLayout=view.findViewById(R.id.collect_LinearLayout);
        activityLinearLayout=view.findViewById(R.id.activity_LinearLayout);
        myOrderLinearLayout=view.findViewById(R.id.my_Order_LinearLayout);
        sweepLinearLayout=view.findViewById(R.id.sweep_LinearLayout);
        navigationLinearLayout=view.findViewById(R.id.navigation_LinearLayout);
        mapLinearLayout=view.findViewById(R.id.map_LinearLayout);
        helpLinearLayout=view.findViewById(R.id.help_LinearLayout);
        myBalanceLinearLayout=view.findViewById(R.id.my_balance_LinearLayout);
        memberLinearLayout=view.findViewById(R.id.memberLinearLayout);
        dynamicLinearLayout=view.findViewById(R.id.dynamicLinearLayout);
        wusiLinearLayout=view.findViewById(R.id.wusiLinearLayout);
        MyBanner banner=new MyBanner(getActivity(),view);
        banner.init();
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        searchLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"点击跳转电站搜索界面",Toast.LENGTH_SHORT).show();
            }
        });
        collectLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"功能还未上线",Toast.LENGTH_SHORT).show();
            }
        });
        activityLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"点击跳转活动中心界面",Toast.LENGTH_SHORT).show();
            }
        });
        myOrderLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"点击跳转我的订单界面",Toast.LENGTH_SHORT).show();
            }
        });
        sweepLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(),CaptureActivity.class);
                startActivity(intent);
            }
        });
        navigationLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"点击跳转一键导航界面",Toast.LENGTH_SHORT).show();
            }
        });
        mapLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"点击跳转充电地图界面",Toast.LENGTH_SHORT).show();
            }
        });
        helpLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"点击跳转充电帮助界面",Toast.LENGTH_SHORT).show();
            }
        });
        memberLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"会员制暂未上线，敬请期待~",Toast.LENGTH_SHORT).show();
            }
        });
        myBalanceLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"会员制暂未上线，敬请期待~",Toast.LENGTH_SHORT).show();
            }
        });
        dynamicLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"会员制暂未上线，敬请期待~",Toast.LENGTH_SHORT).show();
            }
        });
        wusiLinearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getActivity(),"该条动态暂时无法点开~",Toast.LENGTH_SHORT).show();
            }
        });
    }
}

